package com.zyl.pts.service.serviceImpl;

import com.zyl.pts.domain.vo.AnalysisVO.AllCount;
import com.zyl.pts.domain.vo.AnalysisVO.SaleCount;
import com.zyl.pts.mapper.AnalysisMapper;
import com.zyl.pts.service.AnalysisService;
import com.zyl.pts.utils.CUtil;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

/**
 * @version v1.0
 * @ProjectName: product_source
 * @Package: com.zyl.pts.service.serviceImpl
 * @ClassName: AnalysisServiceImpl
 * @Description TODO()
 * @Author 翟玉龙
 * @Date 2024/11/18-14:17
 */
@Service
public class AnalysisServiceImpl implements AnalysisService {

    private final AnalysisMapper analysisMapper;

    public AnalysisServiceImpl(AnalysisMapper analysisMapper) {
        this.analysisMapper = analysisMapper;
    }


    @Override
    public AllCount getCount() {
        List<Integer> lists = analysisMapper.getCount();
        return new AllCount().setValue(lists);
    }

    /**
     * 统计动物体重信息
     * @return {@link Map }<{@link String }, {@link Long }>
     */
    @Override
    public Map<String, ?> getIndexCount() {
        List<Map<String, Object>> lists = analysisMapper.getIndexCount();
        CUtil.logInfo(lists.toString());
        return CUtil.listToMap(lists, "weight_range", "count", Long.class);
    }

    /**
     * 统计动物病症数量
     * @return {@link Map }<{@link String }, {@link Long }>
     */
    @Override
    public Map<String, ?> getDiseaseCount() {
        List<Map<String, Object>> lists = analysisMapper.getDiseaseCount();
        return CUtil.listToMap(lists, "disease_type", "count", Long.class);
    }

    /**
     * 统计本年度12个月销售动物
     * @return {@link List }<{@link Integer }>
     */
    @Override
    public SaleCount getSaleCount() {
        List<Integer> lists = analysisMapper.getSaleCount();
        return new SaleCount().setValue(lists);
    }
}
